public class Map {
	private final int max = 30;
	public int width = max;
	public int height = max;
	public Tile[][] tiles;

	public Map(String[] s) {
		tiles = new Tile[max][max];

		for (int i = 0; i < s.length; i++) {
			for (int j = 0; j < s[0].length(); j++) {
				tiles[i][j] = new Tile(i, j, s[i].charAt(j));
			}
		}
	}

	public void displace(int xFrom, int yFrom, int xTo, int yTo, Tileable t) {
		this.tiles[yFrom][xFrom].remTileable(t.getID());
		this.tiles[yTo][xTo].putTileable(t);
	}

	public void remTileable(int x, int y, Tileable t) {
		this.tiles[y][x].remTileable(t.getID());
	}

	public void putTileable(int x, int y, Tileable t) {
		this.tiles[y][x].putTileable(t);
	}

	public char getTileLabel(int x, int y) {
		return tiles[y][x].getLabel();
	}

	public Tile getTile(int x, int y) {
		return tiles[y][x];
	}

	public int width() {
		return this.width;
	}

	public int height() {
		return this.height;
	}

	public String toString() {
		String s = "";
		for (int i = 0; i < max; i++) {
			for (int j = 0; j < max; j++) {
				s += tiles[i][j].getLabel();
			}
			s += "\n";
		}
		return s;
	}
}
